package com.corex.vinayak;

import com.corex.listadapters.ExamQuestionNumberAdpter;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.GridView;
import android.widget.Toast;

public class ExamQuestionListActivity extends Activity{
	GridView grid;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		final String[] web = new String[50];
		
		for (int i = 0; i < 50; i++) {
			web[i] = ""+(i+1);
		}
		
		setContentView(R.layout.exam_question_list);
	    ExamQuestionNumberAdpter  examQuestionNumberAdpter =  new ExamQuestionNumberAdpter(ExamQuestionListActivity.this, web);
	    grid=(GridView)findViewById(R.id.grid);
	        grid.setAdapter(examQuestionNumberAdpter);
	        grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
	                @Override
	                public void onItemClick(AdapterView<?> parent, View view,
	                                        int position, long id) {
	                    Toast.makeText(ExamQuestionListActivity.this, "You Clicked at " +web[+ position], Toast.LENGTH_SHORT).show();
	                }
	            });
	        
	        grid.setOnItemLongClickListener(new OnItemLongClickListener() {

				@SuppressLint("NewApi")
				@Override
				public boolean onItemLongClick(AdapterView<?> parent, View view,
						int pos, long id) {
					view.setBackground(getResources().getDrawable(R.drawable.roundedborder_no_padding));
					return false;
				}
	        	
			});
	  }
}
